import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'
import ContentLayout from '@/views/layout/ContentLayout'

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirct in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
**/
export const constantRouterMap = [
  { path: '/login', component: () => import('@/views/login/index'), hidden: true },
  { path: '/404', component: () => import('@/views/404'), hidden: true },
  {
    path: '/',
    component: ContentLayout,
    redirect: '/home',
    hidden: true,
    children: [{
      path: 'home',
      component: () => import('@/views/home/index')
    }]
  },
  {
    path: '/monitor',
    component: ContentLayout,
    hidden: true,
    children: [{
    path: '/',
    component: () => import('@/views/monitor/index')
    },
    {
    path: 'track',
      component: () => import('@/views/track/index')
    },
    {
    path: 'follow',
      component: () => import('@/views/follow/index')
   }]
  },
  {
    path: '/report',
    component: Layout,
    children: [
      {
        path: 'device',
        component: () => import('@/views/devicetable/index'),
        meta: { title: '设备台账', icon: 'table' }
      },
      {
        path: 'overspeedtable',
        component: () => import('@/views/overspeedtable/index'),
        meta: { title: '超速报表', icon: 'table' }
      }
    ]
  },
  // {
  //   path: '/report',
  //   component: Layout,
  //   children: [
  //     {
  //       path: 'overspeedtable',
  //       component: () => import('@/views/overspeedtable/index'),
  //       meta: { title: '超速报表', icon: 'table' }
  //     }
  //   ]
  // },
  {
    path: '/report',
    component: Layout,
    meta: { title: '报警报表', icon: 'table' },
    children: [
      {
        path: 'warningtable',
        component: () => import('@/views/warningcount/index'),
        meta: { title: '报警统计' }
      },
      {
        path: 'record',
        name: 'Tree',
        component: () => import('@/views/warningrecord/index'),
        meta: { title: '报警记录' }
      }
    ]
  },
  {
    path: '/report',
    component: Layout,
    children: [
      {
        path: 'travelcount',
        component: () => import('@/views/thermodynamic/index'),
        meta: { title: '行驶热力图', icon: 'table' }
      }
    ]
  },
  {
    path: '/report',
    component: Layout,
    meta: { title: '服务费报表', icon: 'table' },
    children: [
      {
        path: 'payment',
        component: () => import('@/views/payment/index'),
        meta: { title: '缴费记录' }
      },
      {
        path: 'expire',
        name: 'expire',
        component: () => import('@/views/expire/index'),
        meta: { title: '到期设备' }
      }
    ]
  },
  {
    path: '/backstage',
    component: Layout,
    children: [
      {
        path: 'deviceadmin',
        component: () => import('@/views/deviceadmin/index'),
        meta: { title: '设备管理', icon: 'table' }
      }
    ]
  },
  {
    path: '/backstage',
    component: Layout,
    children: [
      {
        path: 'users',
        component: () => import('@/views/users/index'),
        meta: { title: '后台用户管理', icon: 'table' }
      }
    ]
  },
  {
    path: '/backstage',
    component: Layout,
    children: [
      {
        path: 'admins',
        component: () => import('@/views/admins/index'),
        meta: { title: '乐骑卫士管理员', icon: 'table' }
      }
    ]
  },
  {
    path: '/backstage',
    component: Layout,
    children: [
      {
        path: 'leqiuser',
        component: () => import('@/views/leqiuser/index'),
        meta: { title: '乐骑卫士用户', icon: 'table' }
      }
    ]
  },
  {
    path: '/backstage',
    component: Layout,
    children: [
      {
        path: 'products',
        component: () => import('@/views/products/index'),
        meta: { title: '商品列表', icon: 'table' }
      }
    ]
  },
  {
    path: '/backstage',
    component: Layout,
    children: [
      {
        path: 'channel',
        component: () => import('@/views/channel/index'),
        meta: { title: '渠道管理', icon: 'table' }
      }
    ]
  },
  {
    path: '/backstage',
    component: Layout,
    children: [
      {
        path: 'role',
        component: () => import('@/views/role/index'),
        meta: { title: '角色管理', icon: 'table' }
      }
    ]
  },
  {
    path: '/backstage',
    component: Layout,
    children: [
      {
        path: 'permissions',
        component: () => import('@/views/permissions/index'),
        meta: { title: '权限列表', icon: 'table' }
      }
    ]
  },
  { path: '*', redirect: '/404', hidden: true }
]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})

